//
// Created by 梦小星 on 2021/10/24.
// @author 梦小星 https://mengxiaoxing.top
// @mail mengxingcn@aliyun.com
//

#include <iostream>
#include "SqList.h"

/*
 * 删除顺序表中在s和t之间的值（s<t）若s或t不合理或者顺序表为空则显示错误信息
 * */
bool DelST(SqList list, int s, int t) {
    if (s >= t || list.length == 0) return false;
    int k = 0;
    for (int i = 0; i < list.length; ++i) {
        if (list.data[i] >= s && list.data[i] <= t) {
            k++;
        } else {
            list.data[i-k]=list.data[i];
        }
    }
    list.length-=k;
    return true;
}
int main() {
    SqList list;
    initList(list);
    int data[] = {3,4,3,5,6,7,8,9,7,5,6,4,3,4};
    int dataSize = sizeof(data) / sizeof(int);
    for (int i = 0; i < dataSize; ++i) {
        list.data[i] = data[i];
        list.length = i;
    }
    DelST(list,3,8);
}

